<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数值增减界面</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      text-align: center;
    }

    #current-value {
      margin-bottom: 10px;
      font-size: 20px;
    }

    input {
      padding: 5px;
      margin-right: 10px;
    }

    button {
      padding: 5px 10px;
    }
  </style>
</head>

<body>
  <div id="current-value">当前值: 0</div>
  <input type="number" id="input-value" placeholder="输入要增减的数值">
  <button onclick="incrementValue()">增加</button>
  <button onclick="decrementValue()">减少</button>

  <script>
    let currentValue = 0;
    const currentValueElement = document.getElementById('current-value');

    function updateValueDisplay() {
      currentValueElement.textContent = `当前值: ${currentValue}`;
    }

    function incrementValue() {
      const input = document.getElementById('input-value').value;
      const num = parseInt(input, 10);
      if (!isNaN(num)) {
        currentValue += num;
      } else {
        currentValue++;
      }
      updateValueDisplay();
    }

    function decrementValue() {
      const input = document.getElementById('input-value').value;
      const num = parseInt(input, 10);
      if (!isNaN(num)) {
        currentValue -= num;
      } else {
        currentValue--;
      }
      updateValueDisplay();
    }

    updateValueDisplay();
  </script>
</body>

</html>